<template>
  <div class="guide-container">
    <!-- 顶部标题栏 -->
    <view class="header animate-fade-in">
      <view class="header-main">
        <view>
          <view class="title">旅游攻略</view>
          <view class="subtitle">发现最地道的旅行体验</view>
        </view>
      </view>
    </view>

    <!-- 分类导航 -->
    <view class="category-scroll animate-slide-in">
      <view class="category-list">
        <view 
          v-for="(item, index) in navItems" 
          :key="index"
          :class="['category-tag', { active: currentContent === item.key }]"
          @tap="loadContent(item.key)"
        >
          <uni-icons :type="getIconType(item)" size="20" :color="currentContent === item.key ? '#333' : '#666'"></uni-icons>
          <text>{{ item.text }}</text>
        </view>
      </view>
    </view>

    <!-- 搜索栏 -->
    <div class="search-bar">
      <input type="text" placeholder="搜索..." v-model="searchQuery" @input="handleSearch" class="search-input" />
      <button @click="handleSearch" class="search-button">搜索</button>
    </div>

    <!-- 内容区域 -->
    <scroll-view class="content-scroll" scroll-y>
      <!-- 住宿内容 -->
      <div v-if="currentContent === 'live'" class="container">
        <view 
          v-for="(item, index) in liveList" 
          :key="index"
          class="module animate-scale-in"
          :style="{ animationDelay: index * 0.1 + 's' }"
        >
          <navigator :url="item.url" open-type="navigate">
            <view class="image-section">
              <image :src="item.image" :alt="item.title" mode="aspectFill" />
            </view>
            <view class="text-section">
              <view class="tu">
                <uni-icons :type="item.icon" size="20"></uni-icons>
                <text class="title">{{ item.title }}</text>
              </view>
              <text class="description">{{ item.description }}</text>
            </view>
            <view class="guide-footer">
              <view class="rating">
                <uni-icons type="star-filled" size="12" color="#ff9900"></uni-icons>
                <text>{{ item.rating }}</text>
              </view>
              <view class="views">
                <uni-icons type="eye" size="12" color="#999"></uni-icons>
                <text>{{ item.views }}浏览</text>
              </view>
            </view>
          </navigator>
        </view>
      </div>

      <!-- 线路内容 -->
      <div v-else-if="currentContent === 'location'" class="container">
        <view 
          v-for="(item, index) in locationList" 
          :key="index"
          class="module animate-scale-in"
          :style="{ animationDelay: index * 0.1 + 's' }"
        >
          <navigator :url="item.url" open-type="navigate">
            <view class="image-section">
              <image :src="item.image" :alt="item.title" mode="aspectFill" />
            </view>
            <view class="text-section">
              <view class="tu">
                <uni-icons :type="item.icon" size="20"></uni-icons>
                <text class="title">{{ item.title }}</text>
              </view>
              <text class="description">{{ item.description }}</text>
            </view>
            <view class="guide-footer">
              <view class="rating">
                <uni-icons type="star-filled" size="12" color="#ff9900"></uni-icons>
                <text>{{ item.rating }}</text>
              </view>
              <view class="views">
                <uni-icons type="eye" size="12" color="#999"></uni-icons>
                <text>{{ item.views }}浏览</text>
              </view>
            </view>
          </navigator>
        </view>
      </div>

      <!-- 吃喝内容 -->
      <div v-else-if="currentContent === 'eat'" class="container">
        <view 
          v-for="(item, index) in eatList" 
          :key="index"
          class="module animate-scale-in"
          :style="{ animationDelay: index * 0.1 + 's' }"
        >
          <navigator :url="item.url" open-type="navigate">
            <view class="image-section">
              <image :src="item.image" :alt="item.title" mode="aspectFill" />
            </view>
            <view class="text-section">
              <view class="tu">
                <uni-icons :type="item.icon" size="20"></uni-icons>
                <text class="title">{{ item.title }}</text>
              </view>
              <text class="description">{{ item.description }}</text>
            </view>
            <view class="guide-footer">
              <view class="rating">
                <uni-icons type="star-filled" size="12" color="#ff9900"></uni-icons>
                <text>{{ item.rating }}</text>
              </view>
              <view class="views">
                <uni-icons type="eye" size="12" color="#999"></uni-icons>
                <text>{{ item.views }}浏览</text>
              </view>
            </view>
          </navigator>
        </view>
      </div>

      <!-- 购物内容 -->
      <div v-else-if="currentContent === 'shop'" class="container">
        <view class="empty-state">
          <uni-icons type="shop" size="48" color="#ddd"></uni-icons>
          <text>暂无记录</text>
        </view>
      </div>
    </scroll-view>
  </div>
</template>

<script>
export default {
  name: 'NavbarComponent',
  data() {
    return {
      searchQuery: '',
      currentContent: 'live', // 设置默认显示
      navItems: [
        { key: 'live', text: '住宿', icon: 'home', filledIcon: 'home-filled' },
        { key: 'location', text: '线路', icon: 'location', filledIcon: 'location-filled' },
        { key: 'eat', text: '吃喝', icon: 'star', filledIcon: 'star-filled' },
        { key: 'shop', text: '购物', icon: 'shop', filledIcon: 'shop-filled' }
      ],
      liveList: [
        {
          url: 'gong1',
          image: '/static/guide/1.jpg',
          title: '广州塔',
          description: '广州塔，又称广州新电视塔，昵称"小蛮腰"，是一座...',
          icon: 'home',
          rating: '4.8',
          views: '12580'
        },
        {
          url: 'gong2',
          image: '/static/guide/2.jpg',
          title: '深圳湾',
          description: '深圳湾是位于广东省深圳市西南部的一片重要海湾，它不仅是深圳的地理标志，也是城市发展和自然生态保护的典范',
          icon: 'home',
          rating: '4.6',
          views: '8920'
        },
        {
          url: 'gong3',
          image: '/static/guide/3.jpg',
          title: '乳源大峡谷',
          description: '广东乳源大峡谷又称广东大峡谷，位于距乳源县西南68公里的大布镇。大峡谷贯穿于韶关的大布镇和英德的波罗镇，全长15公里，最高深切度是400多米，沿途风景优美，被誉为"广东最美丽的峡谷"。',
          icon: 'home',
          rating: '4.7',
          views: '6350'
        }
      ],
      locationList: [
        {
          url: 'gong4',
          image: '/static/guide/7.jpg',
          title: '白云山旅游路线',
          description: '白云山，大致位于广州的东北部，有"羊城第一秀"之称，广州的"母亲山"。',
          icon: 'location',
          rating: '4.9',
          views: '15680'
        },
        {
          url: 'gong5',
          image: '/static/guide/6.jpg',
          title: '佛山祖庙',
          description: '佛山祖庙，名"北帝庙""灵应祠"，位于广东省佛山市禅城区祖庙路21号。供奉道教真武玄天上帝，始建于北宋元丰年间（1078~1085年）...',
          icon: 'location',
          rating: '4.5',
          views: '7890'
        }
      ],
      eatList: [
        {
          url: 'gong6',
          image: '/static/guide/4.jpg',
          title: '潮汕肠粉',
          description: '广东潮汕小吃 潮汕肠粉，包括（汕头肠粉、普宁肠粉、惠来肠粉、饶平肠粉、潮州肠粉、潮阳肠粉），都属于潮汕肠粉范筑。',
          icon: 'fire',
          rating: '4.7',
          views: '9860'
        },
        {
          url: 'service4',
          image: '/static/guide/5.jpg',
          title: '凉茶',
          description: '凉茶，流行于中国广东省、香港特别行政区、澳门特别行政区的传统技艺，国家级非物质文化遗产之一。',
          icon: 'fire',
          rating: '4.4',
          views: '5670'
        }
      ]
    };
  },
  methods: {
    handleSearch() {
      console.log('搜索:', this.searchQuery);
    },
    loadContent(content) {
      this.currentContent = content;
    },
    getIconType(item) {
      return this.currentContent === item.key ? item.filledIcon : item.icon;
    }
  }
};
</script>

<style scoped>
.guide-container {
  padding: 20px;
  background: linear-gradient(to bottom, #f8f8f8, #fff);
  min-height: 100vh;
}

.header {
  margin-bottom: 20px;
}

.title {
  font-size: 32px;
  font-weight: bold;
  background: linear-gradient(45deg, #333, #666);
  -webkit-background-clip: text;
  color: transparent;
  margin-bottom: 6px;
}

.subtitle {
  font-size: 14px;
  color: #999;
  letter-spacing: 0.5px;
}

.category-scroll {
  margin: 0 -20px 20px;
  overflow: hidden;
  padding: 0 15px;
}

.category-list {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 8px;
}

.category-tag {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 4px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  min-width: 0;
}

.category-tag.active {
  background: #ffe4e1;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.15);
  scale: 1.02;
}

.category-tag uni-icons {
  margin-right: 2px;
  font-size: 18px;
}

.category-tag text {
  margin-left: 2px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-bar {
  margin: 20px 0;
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.search-input {
  flex: 1;
  padding: 8px 12px;
  border: none;
  font-size: 14px;
  background: transparent;
}

.search-button {
  padding: 8px 16px;
  background: linear-gradient(135deg, #42b983 0%, #3aa876 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
}

.content-scroll {
  height: calc(100vh - 240px);
}

.module {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  margin-bottom: 20px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(0,0,0,0.03);
}

.module:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.image-section {
  position: relative;
  padding-top: 56.25%;
  overflow: hidden;
}

.image-section image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.module:hover .image-section image {
  transform: scale(1.05);
}

.text-section {
  padding: 16px;
}

.text-section .tu {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.text-section .title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0;
  background: none;
  -webkit-background-clip: unset;
}

.text-section .description {
  font-size: 14px;
  color: #666;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.guide-footer {
  padding: 12px 16px;
  border-top: 1px solid #f5f5f5;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rating, .views {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rating text {
  color: #ff9900;
  font-size: 14px;
  font-weight: 500;
}

.views text {
  color: #999;
  font-size: 13px;
}

/* 动画效果 */
.animate-fade-in {
  animation: fadeIn 0.8s ease-out;
}

.animate-slide-in {
  animation: slideIn 0.6s ease-out;
}

.animate-scale-in {
  animation: scaleIn 0.5s ease-out forwards;
  opacity: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 响应式设计 */
@media screen and (min-width: 768px) {
  .container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
  
  .module {
    margin-bottom: 0;
  }
}
</style>